<?php

class ScheduleHandler{

private $schedulesearch;
private $schedulecat;
private $con;

public function setSchedule($schedule){

$this->schedulesearch=$schedule;
}

public function setCat($cat){

$this->schedulecat=$cat;

}

public function setConnect($conn){

$this->con=$conn;

}  



public function scheduleAdd ($subgr,$days,$start,$end,$empno,$class){


$sql1="insert into class_sched (sub_gr,days,start,end,emp_no,class_no) values('$subgr','$days','$start','$end','$empno','$class')";

mysql_query($sql1,$this->con) or die(mysql_error());

$msg="Succesfully Added";
return $msg;

}



public function getPageSearch($startrow,$limit){

$sql=" select class_sched.schedule_id,subject_code.subject,subject_code.grade,subject_code.c_fee,subject_code.sub_gr,class_sched.days,class_sched.start,   class_sched.end from
subject_code,class_sched where subject_code.sub_gr=class_sched.sub_gr order by class_sched.schedule_id desc Limit $startrow,$limit";

$result=mysql_query($sql,$this->con)or die(mysql_error());

return $result;

}






public function scheduleUpdate($id,$subgr,$days,$start,$end,$empno,$class){


$sql="update class_sched set sub_gr='$subgr',days='$days',start='$start',end='$end',emp_no='$empno',class_no='$class' where schedule_id='$id'";

mysql_query($sql,$this->con) or die(mysql_error());

$msg="Sccessfully Updated";

return $msg;



}



public function getSearch($startrow,$limit){



if($this->schedulecat=="Grade"){

$sql=" select class_sched.schedule_id,subject_code.subject,subject_code.grade,subject_code.sub_gr,subject_code.c_fee,class_sched.days,class_sched.start,   class_sched.end from
subject_code,class_sched where subject_code.sub_gr=class_sched.sub_gr and subject_code.grade ='$this->schedulesearch' order by class_sched.schedule_id desc Limit $startrow,$limit";


 } else {
 $sql=" select class_sched.schedule_id,subject_code.subject,subject_code.grade,subject_code.sub_gr,subject_code.c_fee,class_sched.days,class_sched.start,   class_sched.end from
subject_code,class_sched where subject_code.sub_gr=class_sched.sub_gr and subject_code.subject ='$this->schedulesearch' order by class_sched.schedule_id desc Limit $startrow,$limit";

}
$result=mysql_query($sql,$this->con)or die(mysql_error());
return $result;
}





public function getDelete($id){


$sql2="delete  from class_sched where schedule_id='$id' ";

mysql_query($sql2,$this->con) or die(mysql_error());

$msgd="sccessfully deleted";
return $msgd;
}



public function getPaginationRow(){



if($this->schedulecat=="Grade"){

$sql=" select class_sched.schedule_id,subject_code.subject,subject_code.grade,subject_code.sub_gr,subject_code.c_fee,class_sched.days,class_sched.start,   class_sched.end from
subject_code,class_sched where subject_code.sub_gr=class_sched.sub_gr and subject_code.grade ='$this->schedulesearch'";


 } else {
 $sql=" select class_sched.schedule_id,subject_code.subject,subject_code.grade,subject_code.sub_gr,subject_code.c_fee,class_sched.days,class_sched.start,   class_sched.end from
subject_code,class_sched where subject_code.sub_gr=class_sched.sub_gr and subject_code.subject ='$this->schedulesearch'";

 
 
 
 }
$result=mysql_query($sql,$this->con)or die(mysql_error());
return $result;
}




}

?>